﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace PMC.Structs
{
    public enum ExpressionTypes { Expression, Exception }
    [DataContract]
    public struct Expressions
    {
        public Expressions(string expression, ExpressionTypes type) : this()
        {
            Expression = expression;
            Type = type;
        }

        [DataMember]
        public string Expression { get; set; }
        [DataMember]
        public ExpressionTypes Type { get; set; }

        public override string ToString()
        {
            return Expression;
        }

        /// <summary>
        /// Returns the expression as string
        /// </summary>
        /// <param name="exp"></param>
        /// <returns></returns>
        public static implicit operator string(Expressions exp)
        {
            return exp.Expression;
        }

        public override int GetHashCode()
        {
            return Expression.GetHashCode() ^ Type.GetHashCode();
        }
    }
}
